package tn.orange.canreminder;

import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class PlaceMapActivity extends MapActivity {

	private MapView mapView;

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.map);

		double latitude = getIntent().getExtras().getDouble("latitude");
		double longitude = getIntent().getExtras().getDouble("longitude");
		String nom = getIntent().getExtras().getString("nom");

		int lat = (int) (longitude * Math.pow(10, 6));
		int lon = (int) (latitude * Math.pow(10, 6));

		mapView = (MapView) findViewById(R.id.map_view);
		mapView.setBuiltInZoomControls(true);

		List<Overlay> mapOverlays = mapView.getOverlays();
		Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
		CustomItemizedOverlay itemizedOverlay = new CustomItemizedOverlay(
				drawable, this);

		GeoPoint point = new GeoPoint(lat, lon);
		OverlayItem overlayitem = new OverlayItem(point, "Cafe", nom);

		itemizedOverlay.addOverlay(overlayitem);
		mapOverlays.add(itemizedOverlay);

		MapController mapController = mapView.getController();

		mapController.setCenter(point);
		mapController.setZoom(16);
		mapView.setSatellite(true);

	}

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}

}